package com.haoniu.framework.redis;


import com.haoniu.framework.web.service.RedisService;
import com.haoniu.system.domain.SysConfig;
import com.haoniu.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * 描述:
 * 加载SysConfig表中的数据到redis
 *
 * @author shilvfei
 * @create 2018-11-24 9:37
 */
@Component
public class RedisInitializeSysConfig {

    @Autowired
    private ISysConfigService sysConfigService;

    @Autowired
    private RedisService redisService;

    @PostConstruct
    public void loadingRedisFromDb() {
        //加载到redis中
        List<SysConfig> sysConfigList = sysConfigService.selectConfigList(null);
        for (SysConfig sysConfig:sysConfigList) {
            redisService.setConfig(sysConfig.getConfigKey(),sysConfig.getConfigValue());
        }
    }
}
